package com.mohan.config;

import com.mohan.aop.impl.*;
import com.mohan.bean.Car;
import com.mohan.bean.Color;
import com.mohan.bean.Person;
import com.mohan.bean.Red;
import org.springframework.context.annotation.*;

@Configuration
@Import({Color.class, Red.class, MyImportSelector.class, MyImportBeanDefinitionRegistar.class})        //@Import快速地注入容器，id默认是组件的全类名
public class MainConfig3 {
    @Bean("person")
    @Lazy
    public Person person() {
        System.out.println("给容器中添加这个对象。。。");
        return new Person("美羊羊", 18);
    }

    @Bean("bill")
    @Conditional(WindowsCondition.class)
    public Person person1() {
        return new Person("bill", 19);
    }

    @Bean("linus")
    @Conditional(LinuxCondition.class)
    public Person person02() {
        return new Person("linus", 20);
    }

    @Bean
    public ColorFactoryBean colorFactoryBean() {
        return new ColorFactoryBean();
    }

    @Bean(initMethod = "init",destroyMethod = "destory")
    public Car car() {
        return new Car("1313","1313");
    }
}
